/*
 * @Author: your name
 * @Date: 2020-06-05 09:40:29
 * @LastEditTime: 2020-08-20 11:26:43
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \shkg-web-detentionHouse-webSite\src\api\user.js
 */
import { json2form } from '@/utils/index.js'
import request from '@/utils/request'
/**
 * @description: 登录
 * @param {Object} data
 * account：账号
 * password：密码
 * @returns {Object}
 */
export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

/**
 * @description: 登录
 * @param {Object} data
 * account：账号
 * password：密码
 * @returns {Object}
 */
export function loginAuthorization(data) {
  return request({
    url: '/oauth/token',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': 'Basic c3VuZmx5OnN1bmZseQ=='
    },
    data: json2form(data)
  })
}

/**
 * @description: 登出
 * @param {Object} data
 * token：当前用户token
 * @returns {Object}
 */
export function logout(data) {
  return request({
    url: '/user/logout',
    method: 'post',
    data
  })
}

/**
 * @description: 获取当前用户信息
 * @param {Object} data
 * token：当前用户token
 * @returns {Object}
 */
export function getInfo(token) {
  return request({
    url: '/user/me',
    method: 'get'
  })
}
